package com.clark.dingding.retrofit.repository

import com.clark.dingding.retrofit.ApiClient.dynamicDataService
import com.linkage.linkedlife.utils.JsonUtil
import com.linkage.linkedlife.utils.SwitchSchedulers
import io.reactivex.Observable

/**
 * @ClassName: DynamicDataRepository
 * @Description: java类作用描述
 * @Author: Clakr
 * @Date: 2020/12/11 0011 11:31
 */

object DynamicDataRepository {

    fun <T> getDynamicData(pullUrl: String, clazz:Class<T>): Observable<T>? {
        return dynamicDataService
            .getDynamicApiService(pullUrl)
            ?.compose(SwitchSchedulers.applySchedulers())
            ?.map{ responseBody -> JsonUtil.Str2JsonBean(responseBody?.string(),clazz)}

    }
}